CREATE DATABASE Mobile
GO

USE Mobile
GO

CREATE TABLE Provider
(
	Id int identity(1,1) primary key,
	Name nvarchar(50)
)

CREATE TABLE Product
(
	Id int identity(1,1) primary key,
	ProviderId int constraint fk_ProviderId foreign key references Provider(Id),
	Name nvarchar(50),
	[Description] nvarchar(max),
	Quantity int,
	Price decimal
)

CREATE TABLE Customer
(
	Id int identity(1,1) primary key,
	Name nvarchar(50)
)

CREATE TABLE [Order]
(
	Id int identity(1,1) primary key,
	OrderNumber varchar(20),
	OrderDate date,
	CustomerId int constraint fk_CustomerId foreign key references Customer(Id),
)

CREATE TABLE OrderDetail
(
	Id int identity(1,1) primary key,
	OrderId int constraint fk_OrderId foreign key references [Order](Id),
	Quantity int,
	ProductId int constraint fk_ProductId foreign key references Product(Id),
)